<template xmlns:box-shadow="http://www.w3.org/1999/xhtml">
  <div class="app-container">


    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="检查项目" prop="examId">
        <el-button-group>
          <el-button
            v-for="exam in checkName"
            :key="exam.examId"
            :label="exam.examName"
            :value="exam.examId" type="primary" @click="changeExamId(exam.examName)"  style="width: 100px"  plain>{{exam.examName}}
          </el-button>
        </el-button-group>
      </el-form-item>
    </el-form>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="检查单号" prop="examName">
        <el-input
          v-model="queryParams.checkCode"
          placeholder="请输入检查单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
      </el-form-item>
    </el-form>





    <hr/>
    <el-row>
      <el-col :span="24" >
        <div style="margin-left: 40px;box-shadow: 12px 12px 12px rgba(0,0,0,0.1)" class="grid-content bg-purple-dark" >
        <br>
          <el-col :span="24" v-if="checkList!=null&&checkList.length!=0"   >
            <el-card>

              <div class="el-table el-table--enable-row-hover el-table--medium">
                <table cellspacing="0" style="width: 100%;">
                  <thead>
                  <tr>
                    <th><div class="cell">患者编号：<span v-text="checkList.patiID"></span></div></th>
                    <th><div class="cell">患者姓名：<span v-text="checkList.patiName"></span></div></th>
                  </tr>
                  </thead>
                  <tbody>
                  <tr>
                    <td><div class="cell">检查项目：<span v-text="checkList.examName"></span></div></td>
                    <td><div class="cell">检查备注：<span v-text="checkList.remark==null?'无':checkList.remark"></span></div></td>
                  </tr>
                  </tbody>
                </table>
              </div>
              <div><el-button type="primary" @click="open2" style="width: 100%">开始检测</el-button></div>
            </el-card>
          </el-col>
          <el-col :span="24" v-if="checkList==null">
            <div style="margin-left: 40px;box-shadow: 12px 12px 12px rgba(0,0,0,0.1)" class="grid-content bg-purple-dark" >
              <h4 align="center" style="color: gray">暂无数据</h4>
            </div>
          </el-col>
        <br>
        </div>
      </el-col>
    </el-row>

  </div>
</template>

<script>
import { listMenu, getCheck, ChangeCheckStatus, addMenu, updateMenu,checkNamelist } from "@/api/examine/check";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";

export default {
  name: "index",

  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 显示状态数据字典
      visibleOptions: [],
      // 菜单状态数据字典
      statusOptions: [],
      //检查项目
      checkName:[],
      // 查询参数
      checkList:null,
      queryParams: {
        //选定检查项目ID
        examName: undefined,
        checkCode:undefined
      },

      // 表单参数
      form: {},
    };
  },
  created() {
    this.getCheckName();


    /*this.getDicts("sys_show_hide").then(response => {
      this.visibleOptions = response.data;
    });
    this.getDicts("sys_normal_disable").then(response => {
      this.statusOptions = response.data;
    });*/
  },
  methods: {
    open2() {
      ChangeCheckStatus(this.queryParams).then(response => {
        this.handleQuery()
        console.log(response)
        if (response.code>0){
          this.$message({
            showClose: true,
            message: '恭喜你，这是一条成功消息',
            type: 'success'
          });}

      });

    },
    // 选择图标
    selected(name) {
      this.form.icon = name;
    },
    getList() {
      getCheck(this.queryParams).then(response => {
        this.checkList = response.data
      });
    },

    /** 查询检查项目名称*/
    getCheckName(){
      this.loading = true;
      checkNamelist().then(response=>{
        this.checkName=response.data;
        this.loading=false;
      })
    },
    changeExamId(examName){
      this.queryParams.examName = examName;
      console.log(this.queryParams.examName)
    },
    /** 查询菜单下拉树结构 */
    getTreeselect() {
      listMenu().then(response => {
        this.menuOptions = [];
        const menu = { menuId: 0, menuName: '主类目', children: [] };
        menu.children = this.handleTree(response.data, "menuId");
        this.menuOptions.push(menu);
      });
    },
    // 显示状态字典翻译
    visibleFormat(row, column) {
      if (row.menuType == "F") {
        return "";
      }
      return this.selectDictLabel(this.visibleOptions, row.visible);
    },
    // 菜单状态字典翻译
    statusFormat(row, column) {
      if (row.menuType == "F") {
        return "";
      }
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        menuId: undefined,
        parentId: 0,
        menuName: undefined,
        icon: undefined,
        menuType: "M",
        orderNum: undefined,
        isFrame: "1",
        isCache: "0",
        visible: "0",
        status: "0"
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    handlechange(){

    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

  }
};
</script>
